Skip to content

fix(cwd): fish style keeps emoji and UNC roots, and (s)egments applies in fish mode - #803

Merged
sirmalloc merged 5 commits into
sirmalloc:mainfrom
eric-engberg:fix/cwd-fish-style
Nov 6, 2026
Merged

sirmalloc merged 5 commits into
sirmalloc:mainfrom
eric-engberg:fix/cwd-fish-style

Conversation

@eric-engberg

Copy link
Copy Markdown
Contributor

What

Three fixes to Current Working Dir's fish style:

  1. A middle folder whose name starts with an emoji now keeps the whole emoji instead of printing a replacement character (�). This also covers emoji right after a hidden folder's dot. A decomposed accented letter keeps its accent.
  2. A Windows UNC cwd keeps its root. \\server\share\team\repo shows as \\server\s\t\repo instead of server\s\t\repo, and //server/share/team/repo keeps both slashes.
  3. Saving a segment count with (s)egments while fish style is on now turns fish style off and applies the count, the same way the (h)ome ~ option already turns fish style off. Before, the count was stored but hidden, then took effect later when fish style was turned off.
    • Settings that already hold both, saved by the old editor or edited by hand, no longer bring a hidden count back. Turning fish style off now clears the count too, and the full path shows.

Why (evidence)

  1. abbreviatePath shortened each middle folder with part[0], or '.' + part[1] for hidden folders. Both index UTF-16 code units, so a character outside the Basic Multilingual Plane was cut in half. With fish style on, a cwd of $HOME/🚀 rockets/sub/last printed cwd: ~/ + EF BF BD + /s/last under both Bun and Node (built dist): the lone surrogate reaches stdout as U+FFFD. .😀x became .�, a decomposed Über became U, and a joined family emoji became �.

  2. The same function splits on /[\\/]+/, drops the empty pieces, and puts a separator back only when the path starts with /. So a path starting with \\ lost its root entirely, and one starting with // kept one slash:

    • \\server\share\team\repo became server\s\t\repo
    • \\wsl.localhost\Ubuntu\home\me\project became wsl.localhost\U\h\m\project
    • //server/share/team/repo became /server/s/t/repo

    docs/WINDOWS.md promises full support for UNC paths. Segments mode never makes a UNC path look relative: it shows the path whole, or cut to ...\team\repo.

  3. Fish style and the segment count are meant to be exclusive: turning fish style on clears the count, and turning on (h)ome ~ turns fish style off. The segments editor kept both. With fish style on, pressing s, typing 2 and pressing Enter left the item at "(fish-style)" and the preview at ~/D/P/my-project, while the settings now held {"fishStyle":"true","segments":"2"}. Pressing f later showed "(segments: 2)" and cut /srv/work/projects/alpha/beta to .../alpha/beta. Turning fish style off removed only fishStyle, so the same happens with any settings file that already holds both.

How

  1. Take the first grapheme, plus the one after the dot for hidden folders, with the existing getGraphemes helper that the glyph and Custom Symbol editors use.
  2. Keep the path's leading separators exactly as given and join the shortened parts after them. Paths under home (~) and drive-letter paths have no leading separators. POSIX paths keep their single /.
  3. When the segments editor saves a count, it drops fishStyle. A blank entry still only clears the count. (s)egments stays available in fish mode, like (h)ome ~, so whichever option was picked last applies right away.
    • Turning fish style off (f) now drops segments along with fishStyle. Turning fish style on already clears the count, so the two can only sit together in settings saved by the old editor or edited by hand.

Left as is:

  • Because the leading separators are kept as given, a POSIX path that starts with // keeps both slashes, the same as a forward-slash UNC path (on main it showed one). process.cwd() reports such a directory with one slash, but bash's pwd keeps both after cd //srv.

Demo

Emoji and decomposed accents. Piped renders of Model + Current Working Dir with fish style on, before (main) and after. The middle folders start with 🚀, with 🔒 after a hidden folder's dot, and with a decomposed Ü. A plain ASCII path is included as a control. The joined family emoji is left out because VHS's terminal draws the parts of a joined emoji separately; the unit test and the built-CLI check below cover it.

Powerline

Before:

Fish-style cwd with emoji folders before the fix, Powerline

After:

Fish-style cwd with emoji folders after the fix, Powerline

Plain

Before:

Fish-style cwd with emoji folders before the fix, Plain

After:

Fish-style cwd with emoji folders after the fix, Plain

UNC paths. The same piped renders with \\server\share, \\wsl.localhost and //server, with a drive-letter path as a control.

Powerline

Before:

Fish-style cwd with UNC paths before the fix, Powerline

After:

Fish-style cwd with UNC paths after the fix, Powerline

Plain

Before:

Fish-style cwd with UNC paths before the fix, Plain

After:

Fish-style cwd with UNC paths after the fix, Plain

(s)egments while fish style is on. In the TUI: s, 2, Enter on a fish-style Current Working Dir. Before, nothing visible changes. After, the item reads "(segments: 2)" and the preview shows the last two folders.

Powerline

Before:

Segments edit in fish mode before the fix, Powerline

After:

Segments edit in fish mode after the fix, Powerline

Plain

Before:

Segments edit in fish mode before the fix, Plain

After:

Segments edit in fish mode after the fix, Plain

Fish style off, with a count already saved next to it. The settings hold fishStyle and segments: 2, as the old segments editor left them. The item reads "(fish-style)"; press f. Before, the hidden count takes over: "(segments: 2)" and .../Projects/my-project. After, the item has no modifier and the preview shows the full sample path.

Powerline

Before:

Fish style turned off with a saved segment count before the fix, Powerline

After:

Fish style turned off with a saved segment count after the fix, Powerline

Plain

Before:

Fish style turned off with a saved segment count before the fix, Plain

After:

Fish style turned off with a saved segment count after the fix, Plain

Testing

  • On main as of fix(powerline): keep the Custom theme when Powerline is enabled again #793 (a0bedc0): it merges after one test conflict next to feat(widgets): add Zed as an IDE link mode #800's Zed case, resolved by keeping both. bun run lint is clean, and bun test gives 4156 pass, 0 fail (4147 on main). The built CLI under Bun 1.4.4 and Node 26.13.0 agrees across runtimes and matches main in plain and Powerline mode, and the TUI opens and exits cleanly under both. It adds no JavaScript or Node API newer than Node 14, the build's target.

  • 9 new tests:

    • 4 fish-style grapheme cases in CurrentWorkingDir.test.ts: emoji, joined emoji, emoji after a dot, decomposed accent
    • 3 root cases in CurrentWorkingDir.test.ts: \\server, //server, and a drive-letter control
    • 1 handleEditorAction case in CurrentWorkingDir.test.ts: turning fish style off with {fishStyle, segments} saved drops both
    • 1 Ink test in ItemsEditor.test.ts that presses s, 2, Enter on a fish-style Current Working Dir

    Run against main's code, the 8 non-control tests fail and the drive-letter control passes.

  • Node 26.10.0 vitest on the two changed test files:

    • ItemsEditor.test.ts: 14/14 pass (main: 13/13).
    • CurrentWorkingDir.test.ts: fails every test on both main and this branch, with the same error in its existing beforeEach (vi.spyOn(os, 'homedir'): "Module namespace is not configurable in ESM"). That is 33 failures on main and 41 here, all with that one error. With the spy line removed locally, the 8 new cases in that file pass under Node.
  • Built CLI under Bun 1.4.2 and Node 26.10.0, piping 9 cwd values through a fish-style line. Both runtimes printed identical output: ~/🚀/s/last, ~/.😀/s/last, /x/Ü/y, /a/👨‍👩‍👧/b, \\server\s\t\repo, \\wsl.localhost\U\h\m\project and //server/s/t/repo. The drive-letter and POSIX controls (C:\U\m\p\sub, /srv/w/p/a/beta) match main.

  • Built CLI under Bun and Node, in plain and Powerline modes:

    • Default demo line: identical across runtimes and the same as main.
    • Fish-style cwd line with an emoji payload and with a UNC payload: identical across runtimes, and different from main as expected.
    • The TUI main menu opens and exits cleanly under both runtimes.

Fish style shortens each middle directory to its first character, but it
took that character with part[0] (and part[1] after a leading dot), which
index UTF-16 code units. A folder whose name starts with an emoji or other
character outside the Basic Multilingual Plane was cut in half, leaving a
lone surrogate that the terminal prints as U+FFFD: "~/🚀 rockets/sub/last"
showed as "~/�/s/last". A decomposed accented name such as "Über" lost its
combining mark, and a joined emoji such as "👨‍👩‍👧" printed as U+FFFD
too.

Take the first grapheme instead, using the getGraphemes helper the symbol
editors already use, so the abbreviation keeps one whole user-visible
character, including after the dot of a hidden directory.
Fish style splits the path on separators, drops the empty pieces and then
rebuilds it, putting a single separator back only when the path started
with '/'. A Windows UNC path lost its leading '\\' entirely, so
"\\server\share\team\repo" showed as the relative-looking
"server\s\t\repo", and "//server/share/team/repo" kept only one of its two
slashes.

Keep the path's leading separators as they were and join the shortened
parts after them. POSIX paths keep their '/', home and drive-letter paths
have no leading separators and come out as before.
Fish style and the segment count are mutually exclusive: turning fish
style on clears the segment count, and turning on the home ~ option turns
fish style off. The (s)egments editor broke that rule. It is offered while
fish style is on, but on Enter it kept fish style and stored the count
next to it. Fish style wins when both are set, so the item still read
"(fish-style)" and the preview and status line didn't change, as if the
edit had been dropped. The hidden count then cut the path the moment fish
style was turned off.

Saving a segment count now turns fish style off, the same way the home ~
option does, so the count takes effect as soon as it is entered and the
item shows it. A blank entry still only clears the count.

Settings saved before this fix, or edited by hand, can still hold both.
Turning fish style off now drops the segment count as well, so the full
path comes back instead of a count that was never shown. Since turning
fish style on already clears the count, it can only sit next to fish
style through the old editor or a hand edit.
# Conflicts:
#	src/tui/components/__tests__/ItemsEditor.test.ts
#	src/widgets/__tests__/CurrentWorkingDir.test.ts
# Conflicts:
#	src/widgets/__tests__/CurrentWorkingDir.test.ts
@sirmalloc
sirmalloc merged commit 2617bd2 into sirmalloc:main Nov 6, 2026
3 checks passed
pcvelz added a commit to pcvelz/ccstatusline-usage that referenced this pull request Nov 13, 2026
Upstream: Extra Usage Today widget (sirmalloc#811), newer usage API percent in an idle session (sirmalloc#767), thinking-effort brackets and per-level colors (sirmalloc#777), 256-color grid in Edit Colors (sirmalloc#778), context bar thin line mode (sirmalloc#794), progress-bar widget consolidation (sirmalloc#810), Zed IDE link mode (sirmalloc#800), Check for Updates deadline and proxy fixes (sirmalloc#806), Configure Status Line before an install (sirmalloc#807), emoji and grapheme fixes (sirmalloc#808, sirmalloc#803, sirmalloc#790), Nerd Font icon width in Ghostty and kitty (sirmalloc#801), cache temp file leak fix (sirmalloc#783), plus TUI, timer and separator fixes.

Hand edits outside conflicts:
- src/tui/components/__tests__/InstallMenu.test.tsx: fork-rename (ccstatusline@ -> ccstatusline-usage@)
- src/utils/__tests__/hooks.test.ts: fork-rename (ccstatusline@ -> ccstatusline-usage@)
- src/tui/__tests__/App.test.ts: fork-rename; upstream's new menu and preview tests step over the fork's Off Hours row and pin cyan where the fork's Model default is ansi256:124
- src/tui/components/__tests__/ColorMenuPalette.test.tsx: fork deviation - Model default is ansi256:124
- src/utils/__tests__/global-package-manager.test.ts: fork deviation - fixture path uses the fork package name ccstatusline-usage
- src/utils/__tests__/migrations.test.ts: fork deviation - flexMode is a post-v1 key in the fork, the v1 sample uses globalBold
- src/utils/__tests__/usage-prefetch.test.ts: fork deviation - stub the provider gate (resolveProvider) in upstream's idle-session and daily-spend tests; the fork reads weekly usage from the API only
- src/utils/__tests__/update-checker.test.ts: lint import order
- src/utils/usage-prefetch.ts: lint - drop the unused fetchUsageData import
- src/widgets/WeeklyFableUsage.ts: compat fix - render through upstream's formatUsageBar (sirmalloc#810) so the line mode works; the inverted cursor follows the shared percent-widget rule
- src/widgets/__tests__/line-bar.test.ts: compat fix - fork WeeklyFableUsageWidget, weeklyFableUsage field and Fable label; block metrics stubbed so the inactive-block case does not read the real cache
- src/widgets/shared/__tests__/usage-display.test.ts: compat fix - the merged cycle has line mode after slider-only
- src/widgets/__tests__/ThinkingEffort.test.ts: keeps the fork's real-settings-file harness, ports upstream's sirmalloc#777 cases onto it
- bun.lock: upstream dependency updates, re-resolved by bun install
- docs/test-retirements.md: ledger for 7 tests upstream replaced (sirmalloc#781 tab as one space, sirmalloc#805 settings write failures, sirmalloc#800 Zed IDE link mode), each naming its replacing test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants